<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生签到系统</title>    <link rel="stylesheet" href="style.css">
    <!-- Vue 3 CDN -->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <!-- 配置文件 -->
    <script src="config.js"></script>
</head>
<body>
    <div id="signin-app">
        <div class="container">
            <div class="form-container">
                <h1 class="title">学生签到</h1>
                
                <!-- 导航链接 -->
                <div class="nav-links">
                    <a href="index.html" class="nav-link">📝 学生登记</a>
                    <a href="signin.html" class="nav-link active">✓ 学生签到</a>
                </div>
                
                <div class="signin-form">
                    <!-- 拍照区域 -->
                    <div class="form-group">
                        <label>人脸识别签到：</label>
                        <div class="camera-container">
                            <!-- 摄像头预览 -->
                            <div v-if="!capturedImage && !showCamera" class="camera-placeholder">
                                <button type="button" @click="startCamera" class="camera-btn">
                                    📷 打开摄像头签到
                                </button>
                            </div>
                            
                            <!-- 摄像头视频流 -->
                            <div v-if="showCamera" class="camera-preview">
                                <video ref="video" autoplay playsinline class="video-preview"></video>
                                <div class="camera-controls">
                                    <button type="button" @click="capturePhoto" class="capture-btn">📸 拍照</button>
                                    <button type="button" @click="stopCamera" class="cancel-btn">❌ 取消</button>
                                </div>
                            </div>
                            
                            <!-- 已拍摄照片 -->
                            <div v-if="capturedImage" class="captured-photo">
                                <img :src="capturedImage" alt="拍摄的照片" class="photo-preview">
                                <div class="photo-controls">
                                    <button type="button" @click="retakePhoto" class="retake-btn">🔄 重新拍照</button>
                                    <button type="button" @click="clearPhoto" class="clear-btn">🗑️ 删除照片</button>
                                </div>
                            </div>
                        </div>
                        <span v-if="errors.photo" class="error">{{ errors.photo }}</span>
                    </div>
                    
                    <!-- 签到按钮 -->
                    <div class="form-group">
                        <button type="button" @click="signIn" class="signin-btn" :disabled="isSubmitting || !capturedImage">
                            <span v-if="isSubmitting">签到中... {{ uploadProgress }}%</span>
                            <span v-else>🎯 立即签到</span>
                        </button>
                    </div>
                </div>
                
                <!-- 签到结果消息 -->
                <div v-if="successMessage" class="success-message">
                    {{ successMessage }}
                </div>
                
                <div v-if="errorMessage" class="error-message">
                    {{ errorMessage }}
                </div>
                
                <!-- 今日签到记录 -->
                <div v-if="todaySignIns.length > 0" class="signin-records">
                    <h2>今日签到记录</h2>
                    <div class="signin-card" v-for="(record, index) in todaySignIns" :key="index">
                        <span class="signin-name">{{ record.name || '未识别学生' }}</span>
                        <span class="signin-time">{{ record.time }}</span>
                        <span class="signin-status" :class="record.status">{{ record.statusText }}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="signin.js"></script>
</body>
</html>
